home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
misc
/
cedbar
/
cedbar.gc
< prev
next >
Wrap
Text File
|
1999-05-17
|
16KB
|
594 lines
G4C
; $VER: CedBar.gc 3.5 ( by dck - 20.8.98 )
; ----------------------------------------------------------------------
; A GUI providing a toolbar for the CygnusEd text editor.
; This is a work in perpetual progress, as I use it myself..
; CygnusEd is a commercial product from ASDG Inc. (AFAIK)
; What we do is define various icons, which we use as if they
; were buttons and send the appropriate rexx command to $cedport,
; which contains the name of the current CEd's arexx port.
; According to your monitor/resolution/font etc the Icon-buttons may
; seem too small or too big - just redesign them to your liking.
; =======================================================================
WINBIG -1 0 625 14 "" ; note : no title - since don't want borders
WinType 000010
; winbackground pattern 3 2 ; try it..
varpath 'cedbar.g/cedmark.g'
UseTopaz ; because it's a non-resizable window
; -----------------------------------------------------------
; on loading
; -----------------------------------------------------------
xOnLoad ; On Loading set the default values...
cedname = CEd ; << **** PUT HERE THE FULL PATH OF CED ********
cedClip = 0
cedMark = 1
cedSend = ""
cedFile = ""
newflag = 0
Update cedbar.gc 1 $cedClip
setgad cedbar.gc 20 HIDE ; hide listview
setgad cedbar.gc 11/12 HIDE ; hide amiga guide & launch mode icons
barmode = NORMAL ; or GUIDE - can add more..
GuiClose cedbar.g ; Close the small window (if it was open)
gosub cedbar.gc StartUpCed ; See which ced is calling us
if $$sys.fsn[0][6] != 'Cygnus' ; if we are called from an other screen
cedscreen = CygnusEdScreen ; get the 1st ced's screen name
instance = $cedport[-1][1]
if $instance > 0
and $instance <= 9
appvar cedscreen $($instance + 1)
else
appvar cedscreen 1
endif
; work around... (screen name is converted to capitals & not found..)
; guiscreen #$cedscreen front ; force ced to front !!! doesn't work !!!
setscreen #this $cedscreen
guiopen cedbar.gc
guiscreen #this front
setscreen #this '*'
else
GuiOpen cedbar.gc
endif
GuiLoad :cedbar.g ; the small bar
GuiLoad :cedMark.g ; the Mark Set/Go window
GuiLoad :cedclip.g ; clipboard viewer
guiload :filereq.gc ; the file requester
; see under which ced we're running..
info gui cedbar.gc
cedscreen = $$win.screen
cedport = rexx_ced
if $cedscreen[0][6] == 'Cygnus' ; make sure it's a ced pubscreen
instance = $cedscreen[-1][1] ; get last letter
if $instance > 1
and $instance <= 9 ; adjust port name (if needed)
appvar cedport $($instance - 1)
endif
endif
; find & load the Gui4Cli extension which provides us with
; extra commands we can use with the CALL command
ifexists port LVFormat
call LVFormat Register ; notify it that we want it too
else
; look in our dir..
extract cedbar.gc guipath mypath
joinfile $mypath lvformat progname
joinfile $progname lvformat progname
ifexists file $progname
run $progname
elseifexists file guis:ext/lvformat/lvformat
run guis:ext/lvformat/lvformat
else
ezreq 'Could not find LVFormat!' OK ''
endif
endif
; -----------------------------------------------------------
; ending events
; -----------------------------------------------------------
xONQuit
GuiQuit cedbar.g ; unload all the other GUIs
GuiQuit cedmark.g
guiquit cedclip.g
guiquit addlink.g
guiquit addeffect.g
guiquit addnode.g
guiquit indent.g
guiquit wrap.g
guiquit filereq.gc
ifexists port LVFormat ; quit out handler
call LVFormat quit
endif
ifexists file t:tempnode
delete t:tempnode
endif
xonfail
guiwindow cedbar.gc resume
; -----------------------------------------------------------
; Routine - Find ced
; -----------------------------------------------------------
xRoutine StartUpCed
local count
count = 1
portname = rexx_ced
; look for any instance of ced
ifexists port ~rexx_ced
while $count < 10
IfExists PORT 'rexx_ced$count'
portname = 'rexx_ced$count'
return
endif
++count
endwhile
else
return
endif
run '$cedname' ; not found - start it up
Wait PORT rexx_ced 30 ; wait for ced to load
if $$RETCODE > 0
ezreq "CygnusEd was not found!" EXIT ""
GuiQuit cedbar.gc
Stop
endif
Wait SCREEN CygnusEdScreen1 30 ; if Screen does not open, use WB
portname = rexx_ced
; -----------------------------------------------------------
; window handling events
; -----------------------------------------------------------
xOnRMB ; rotate the last 8 buttons
; GuiClose cedbar.gc
; GuiOpen cedbar.g
gosub cedbar.gc guichange
XICON 2 0 :icons/wnClose ; the Q icon
ezreq "Last chance..\nQuit ?" YES|CANCEL choice
if $choice = 1
GuiQuit cedbar.gc
endif
XICON 15 1 :icons/right ; the > icon togle big/small windows
GuiClose cedbar.gc
GuiOpen cedbar.g
; -----------------------------------------------------------
; New file
; -----------------------------------------------------------
XICON 30 0 :icons/New
SendRexx $cedport "open new"
; -----------------------------------------------------------
; Open file
; -----------------------------------------------------------
; ----- use "filereq.gc" (if it exists in our dir - else ASL)
XICON 55 0 :icons/Open
newflag = 1 ; set flag to know that we pressed the open button
extract cedbar.gc guipath frqpath
joinfile $frqpath filereq.gc frq
joinfile $frqpath CedFav fav
ifexists file $frq
; get the current filename so we can get it's path
sendrexx $cedport 'status filename'
filename = $$rexxret
extract filename path path
; load & open fireq.gc
extract frq unquote frq
guiload $frq cedbar.gc LoadFile $cedbar.gc/path $fav
else
; if no filereq.gc open normally
SendRexx $cedport "open"
endif
; ----- the routine that will be called from filereq.gc for *every*
; file chosen in it's listview
xroutine LoadFile filename
; if there have been changes made or it's an existing file - open a new file
sendrexx $cedport 'status numchanges'
changes = $$rexxret
if $newflag = 0
or $changes > 0
SendRexx $cedport "open new"
endif
newflag = 0 ; set flag = all next files (multiselected) => open new view
SendRexx $cedport 'open $filename'
; ------ add current path to the filename - store it in cedbar.gc/fn
xroutine makefile fn
local pth
extract cedbar.gc guipath pth
joinfile $pth $fn fn
; -----------------------------------------------------------
; View handling icons
; -----------------------------------------------------------
XICON 80 0 :icons/Big
SendRexx $cedport "expand view"
; -----------------------------------------------------------
; Save as.., Save
; -----------------------------------------------------------
XICON 95 0 :icons/saveas
SendRexx $cedport "save as"
XICON 120 0 :icons/save
SendRexx $cedport "save"
; -----------------------------------------------------------
; Quit
; -----------------------------------------------------------
XICON 145 0 :icons/quit
; get information
sendrexx $cedport 'status numchanges'
changes = $$rexxret
sendrexx $cedport 'status filename'
filename = $$rexxret
sendrexx $cedport 'status totalnumviews'
views = $$rexxret
if $changes > 0
ezreq '$changes changes have been made.\nQuit $filename ?\n' 'Quit|Save & Quit|CANCEL' choice
if $choice = 0
stop
elseif $choice = 2
SendRexx $cedport "save"
; we will quit later..
endif
endif
if $views = 1 ; this is the last file - give him one more chance..
ezreq 'Really quit ?' "Quit!|CANCEL" choice
if $choice = 0
stop
endif
; the guy just won't listen to reason..
guiclose cedbar.gc ; close window so ced can quit
guiclose cedmark.g
guiquit cedbar.gc ; and quit.. (after all commands have executed)
endif
SendRexx $cedport "quit"
; -----------------------------------------------------------
; Cut & Paste
; ---------------